<?php
Class TypePuceDAO
{
	public $connexion;

	public function __construct()
	{
		try {
			$this->connexion = new PDO("mysql:host=".SERVEUR_MYSQL.";dbname=".BASE.";charset=utf8", UTILISATEUR, M2P);
		}
		catch(PDOException $e)
		{
			echo "Erreur : ".$e->getMessage();
			die();
		}
	}


	public function rechercher_type_puce($idtypepuce = null, $idmarquepuce = null)
	{
		$query = "SELECT * "
		."FROM type_puce WHERE 1 ";
		if ($idtypepuce != null){
			$query .= " AND idtypepuce = :idtypepuce ";
		}
		if ($idmarquepuce != null){
			$query .= " AND idmarquepuce = :idmarquepuce ";
		}
		$requette_preparee = $this->connexion->prepare($query);
		if ($idtypepuce != null){
			$requette_preparee->bindValue(":idtypepuce" , $idtypepuce, PDO::PARAM_INT);
		}
		if ($idmarquepuce != null){
			$requette_preparee->bindValue(":idmarquepuce" , $idmarquepuce, PDO::PARAM_INT);
		}
		
		$requette_preparee->execute();
		$typePuces= $requette_preparee->fetchAll(PDO::FETCH_CLASS,'TypePuce');
		return  $typePuces;

	} // rechercher_type_puce


} // TypePuceDAO



?>
